package com.xyw.service.impl;

import java.util.List;

import com.xyw.Dao.UserDao;
import com.xyw.Dao.impl.UserDaoImpl;
import com.xyw.entity.User;
import com.xyw.service.UserBiz;

public class UserBizImpl implements UserBiz{
	UserDao dao=new UserDaoImpl();
	public User login(String name, String pwd) {
		if("".equals(name) || "".equals(pwd)) {
			return null;
		}
		return dao.login(name, pwd);
	}
	
	public boolean deleteByID(int id) {
		return dao.deleteByID(id);
	}
	
	public User update(User user) {
		
		return dao.update(user);	
	}
	
	public User add(User user) {
		
			return dao.add(user);
			
	}
	
	public int getCount() {
		return dao.getCount();
	}
	
	public List<User> queryByPage(int page, int size){
		int count=getCount();
		int pageCount=count%size==0?count / size : (count / size + 1);
		page = page < 1 ? 1 : page;
		page = page > pageCount ? pageCount : page;
		return dao.queryByPage(page, size);
	}

	@Override
	public List<User> queryall() {
		// TODO Auto-generated method stub
		return dao.queryall();
	}

	@Override
	public User queryByID(int id) {
		// TODO Auto-generated method stub
		return dao.queryByID(id);
	}

	@Override
	public User queryByName(String name) {
		// TODO Auto-generated method stub
		return dao.queryByName(name);
	}

	@Override
	public User queryByEmail(String email) {
		// TODO Auto-generated method stub
		return dao.queryByEmail(email);
	}

	@Override
	public List<User> queryByAge(int age) {
		// TODO Auto-generated method stub
		return dao.queryByAge(age);
	}

	@Override
	public User queryByPhone(String phone) {
		// TODO Auto-generated method stub
		return dao.queryByPhone(phone);
	}

	@Override
	public List<User> queryByNickname(String nickname) {
		// TODO Auto-generated method stub
		return dao.queryByNickname(nickname);
	}

	@Override
	public List<User> queryByJurisdiction(String jurisdiction) {
		// TODO Auto-generated method stub
		return dao.queryByJurisdiction(jurisdiction);
	}

	@Override
	public User getShang(int id) {
		// TODO Auto-generated method stub
		return dao.getShang(id);
	}

	@Override
	public User getXia(int id) {
		// TODO Auto-generated method stub
		return dao.getXia(id);
	}

	@Override
	public Boolean updatePwd(String name) {
		// TODO Auto-generated method stub
		return dao.updatePwd(name);
	}

	@Override
	public Boolean checkName(String name) {
		if(name==null || "".equals(name)) {
			return false;
		}
		return dao.checkName(name);
	}

	@Override
	public Boolean checkEmail(String email) {
		if(email==null || "".equals(email)) {
			return false;
		}
		return dao.checkEmail(email);
	}

	@Override
	public Boolean checkPhone(String phone) {
		if(phone==null || "".equals(phone) || phone.length()!=11) {
			return false;
		}
		return dao.checkPhone(phone);
	}

}
